package com.mxy.myapplication.pojo;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

public class ParcelableTest implements Parcelable {


  private String name;
  private int age;
  private ArrayList<Pojo2> pojo2s;

  public ParcelableTest(String name,int age,ArrayList<Pojo2> pojo2s){
    this.age=age;
    this.name=name;
    this.pojo2s=pojo2s;
  }

  private ParcelableTest(Parcel in) {
    name = in.readString();
    age = in.readInt();
    ArrayList<Pojo2> pojo2s = new ArrayList<>();
    in.readList(pojo2s, Pojo2.class.getClassLoader());
    this.pojo2s = pojo2s;
  }

  public static final Creator<ParcelableTest> CREATOR = new Creator<ParcelableTest>() {
    @Override
    public ParcelableTest createFromParcel(Parcel in) {
      return new ParcelableTest(in);
    }

    @Override
    public ParcelableTest[] newArray(int size) {
      return new ParcelableTest[size];
    }
  };

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeString(name);
    dest.writeInt(age);
    dest.writeList(pojo2s);
  }


  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public ArrayList<Pojo2> getPojo2s() {
    return pojo2s;
  }

  public void setPojo2s(ArrayList<Pojo2> pojo2s) {
    this.pojo2s = pojo2s;
  }
}
